<!DOCTYPE html>  
<html>  
  <head>  
    <title>Abstract class</title>  
  </head>
  <body>  
    <script type="text/javascript">
      /**
       * Abstract Class Animal.
       *
       * @class Animal
       */
      class Animal {
        constructor() {
          if (this.constructor == Animal) {
            throw new Error("Abstract classes can't be instantiated.");
          }
        }

        say() {
          throw new Error("Method 'say()' must be implemented.");
        }

        eat() {
          document.write("eating<br>");
        }
      }

      /**
       * Dog.
       *
       * @class Dog
       * @extends {Animal}
       */
      class Dog extends Animal {
        say() {
          document.write("bark<br>");
        }
      }

      /**
       * Horse.
       *
       * @class Horse
       * @extends {Animal}
       */
      class Horse extends Animal {}

      new Dog().eat(); // eating
      new Horse().eat(); // eating

      new Dog().say(); // bark
      //new Horse().say(); // Error: Method say() must be implemented.

      //new Animal(); // Error: Abstract classes can't be instantiated.
    </script> 
  </body>  
</html>